package com.fyx.timedTask;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fyx.config.*;
import com.fyx.entity.*;
import com.fyx.mapper.*;
import com.fyx.modules.system.domain.DictDetail;
import com.fyx.modules.system.repository.DictDetailRepository;
import com.fyx.until.DateUtil;
import com.fyx.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.xml.bind.SchemaOutputResolver;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Slf4j
@Component(value="MaiTask")
public class MaiTask {

    @Resource(name = SecondaryMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate mongoTemplate;

    @Resource(name = SixthMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate sixthMongoTemplate;

    @Resource(name = TenthMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate tenthMongoTemplate;


    @Autowired
    private  MongoTemplate mTemplate;

    @Autowired
    private MaiAdInfoMapper maiAdInfoMapper;

    @Autowired
    private MaiRoomsInfoMapper maiRoomsInfoMapper;

    @Autowired
    private MaiInfoMapper maiInfoMapper;

    @Autowired
    private MaiShareInfoMapper maiShareInfoMapper;

    @Autowired
    private SysDictDetailMapper sysDictDetailMapper;


    @Autowired
    private MongoTemplate mongoT;

    @Resource(name = FiveMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate fiveMongoTemplate;

    @Resource(name = NinethMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate ninethMongoTemplate;

    public void run(){
        log.info("埋点信息统计：执行开始=======================");
        long time = DateUtil.getDayBegin().getTime()/1000;
        long nowTime=new Date().getTime()/1000;
        String tableName=DateUtil.timeStamp2Date(time+"","yyyyMM");;
        if(time==nowTime){
            time=DateUtil.getBeginDayOfYesterday().getTime()/1000;
            if(!DateUtil.timeStamp2Date(time+"","yyyyMM").equals(DateUtil.timeStamp2Date(nowTime+"","yyyyMM"))){
                tableName =DateUtil.timeStamp2Date(time+"","yyyyMM");
            }
        }
        long endTime=time+86400;

        recordAdByChannel(time,endTime,tableName);
        recordShareByChannel(time,endTime,tableName);
        log.info("埋点信息统计：执行完毕=======================");
    }

    public void run1(){
        log.info("埋点信息统计：执行开始=======================");
        long time = DateUtil.getDayBegin().getTime()/1000;

        long nowTime=new Date().getTime()/1000;
        for(time=1686758400;time<=1688486400;time+=86400){
        String tableName=DateUtil.timeStamp2Date(time+"","yyyyMM");;
        if(time==nowTime){
            time=DateUtil.getBeginDayOfYesterday().getTime()/1000;
            if(!DateUtil.timeStamp2Date(time+"","yyyyMM").equals(DateUtil.timeStamp2Date(nowTime+"","yyyyMM"))){
                tableName =DateUtil.timeStamp2Date(time+"","yyyyMM");
            }
        }

        long endTime=time+86400;

        newBodyAdByChannel(time,endTime,tableName);
        }
        log.info("埋点信息统计：执行完毕=======================");
    }

    public void recordAdByChannel(long time,long endTime,String tab){

        String tableName="collect_data_"+tab;
        Object evids[]=new Object[]{1000000044,1000000046,1000000047,1000000048,1000000050,1000000056,1000000057,1000000064,1000000082,1000000104,1000000111,1000000130,1000000131,1000000132,1000000133,1000000134,1000000135,1000000136
                ,1000000137,1000000138,1000000139,1000000140,1000000141,1000000142,1000000143,1000000144,1000000145,1000000146,1000000147,1000000148,1000000149,1000000150,1000000151,1000000152,1000000153,1000000154,1000000155,1000000156,1000000157,1000000160};
        QueryWrapper<SysDictDetail> wrapper1=new QueryWrapper<>();
        wrapper1.eq("dict_id",16);
        wrapper1.le("dict_sort",988);
        wrapper1.orderByDesc("dict_sort");
        List<SysDictDetail> list1=sysDictDetailMapper.selectList(wrapper1);
        SysDictDetail sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("total");
        sysDictDetail1.setDictSort(999);
        list1.add(sysDictDetail1);
        sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("totalcl");
        sysDictDetail1.setDictSort(999);
        list1.add(sysDictDetail1);
        sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("totalapp");
        sysDictDetail1.setDictSort(999);
        list1.add(sysDictDetail1);
        if(list1.size()>0){
            for (SysDictDetail sysDictDetail:list1) {
                MaiAdInfo maiAdInfo = new MaiAdInfo();
                maiAdInfo.setChannel(sysDictDetail.getValue());
                maiAdInfo.setTime((int) time);
                if(sysDictDetail.getDictSort()!=999){
                    if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==987) {
                        if(sysDictDetail.getValue().equals("qq_share")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                            maiAdInfo.setTheFather("h5hzmjxl_qq");
                        }else if(sysDictDetail.getValue().indexOf("gdmj")>-1){
                            maiAdInfo.setTheFather("h5gdmjxl_wechat");
                        }else if(sysDictDetail.getValue().indexOf("hcmj")>-1){
                            maiAdInfo.setTheFather("h5hcmjxl_wechat");
                        }
                        else {
                            maiAdInfo.setTheFather("h5hzmjxl_wechat");
                        }
                    }else if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==900) {
                        maiAdInfo.setTheFather("total");
                    }else if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==910) {
                        maiAdInfo.setTheFather("totalcl");
                    }else if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==920) {
                        maiAdInfo.setTheFather("totalapp");
                    }
                    else {
                        if(sysDictDetail.getValue().equals("h5zhsmjcl_wechat")){
                            maiAdInfo.setTheFather("zsmjxl_total");
                        }else if(sysDictDetail.getValue().indexOf("h5")==-1&&sysDictDetail.getValue().indexOf("gdmj")==0){
                            maiAdInfo.setTheFather(sysDictDetail.getValue().split("_")[0] + "_app_total");
                        }
                        else {
                            maiAdInfo.setTheFather(sysDictDetail.getValue().split("_")[0].replace("h5", "") + "_total");
                        }
                    }
                }
               Criteria criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").in(evids);
                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")||sysDictDetail.getValue().equals("h5gdmjxl_wechat")||sysDictDetail.getValue().equals("h5hcmjxl_wechat")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("invite_channel").exists(false),Criteria.where("invite_channel").is(""));
                    }
                    else {
                        criteria.and("invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 999){
                    if(sysDictDetail.getDictSort()==900||sysDictDetail.getDictSort()==910||sysDictDetail.getDictSort()==920){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                Aggregation aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("num")
                );
                AggregationResults<TaskEntity> ar ;
                if(sysDictDetail.getValue().equals("totalcl")||sysDictDetail.getValue().indexOf("cl_")>0){
                    ar = sixthMongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                } if(sysDictDetail.getValue().equals("totalapp")||(sysDictDetail.getValue().indexOf("gdmj")==0&&sysDictDetail.getDictSort()!=900&&sysDictDetail.getDictSort()!=910)){
                    ar = tenthMongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                }
                else {
                    ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                }
                List<TaskEntity> list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiAdInfo.setUsers((long) list.size());
                }


                if(sysDictDetail.getValue().equals("total")||sysDictDetail.getValue().equals("hcmjxl_red")){
                    maiAdInfo.setWatchWinHbVideo(getNumber(1000000137,1,time,endTime,sysDictDetail,tableName));   //               137
                    maiAdInfo.setFailWatchWinHbVideo(getNumber(1000000137,0,time,endTime,sysDictDetail,tableName));   //

                    maiAdInfo.setWatchLsHbVideo(getNumber(1000000138,1,time,endTime,sysDictDetail,tableName));    //               138
                    maiAdInfo.setFailWatchLsHbVideo(getNumber(1000000138,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchLsCloseInt(getNumber(1000000139,1,time,endTime,sysDictDetail,tableName));    //               139
                    maiAdInfo.setFailWatchLsCloseInt(getNumber(1000000139,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchFailHbVideo(getNumber(1000000140,1,time,endTime,sysDictDetail,tableName));    //               140
                    maiAdInfo.setFailWatchFailHbVideo(getNumber(1000000140,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchInterruptVideo(getNumber(1000000141,1,time,endTime,sysDictDetail,tableName));    //               141
                    maiAdInfo.setFailWatchInterruptVideo(getNumber(1000000141,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchLuckyHbVideo(getNumber(1000000143,1,time,endTime,sysDictDetail,tableName));    //               143
                    maiAdInfo.setFailWatchLuckyHbVideo(getNumber(1000000143,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchLuckyCloseHalf(getNumber(1000000144,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchLuckyCloseHalf(getNumber(1000000144,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchBrokeJjjVideo(getNumber(1000000145,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchBrokeJjjVideo(getNumber(1000000145,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchRedcardVideo(getNumber(1000000146,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchRedcardVideo(getNumber(1000000146,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchGoodcardVideo(getNumber(1000000147,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchGoodcardVideo(getNumber(1000000147,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchBubbleHbVideo(getNumber(1000000148,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchBubbleHbVideo(getNumber(1000000148,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchAwakenHbVideo(getNumber(1000000150,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchAwakenHbVideo(getNumber(1000000150,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchAwakenCloseInt(getNumber(1000000151,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchAwakenCloseInt(getNumber(1000000151,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchQdVideo(getNumber(1000000152,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchQdVideo(getNumber(1000000152,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchShopVideo(getNumber(1000000153,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchShopVideo(getNumber(1000000153,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchPropcardVideo(getNumber(1000000154,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchPropcardVideo(getNumber(1000000154,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchCoinAdd1Video(getNumber(1000000155,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchCoinAdd1Video(getNumber(1000000155,0,time,endTime,sysDictDetail,tableName));

                    maiAdInfo.setWatchCoinAdd2Video(getNumber(1000000156,1,time,endTime,sysDictDetail,tableName));    //               144
                    maiAdInfo.setFailWatchCoinAdd2Video(getNumber(1000000156,0,time,endTime,sysDictDetail,tableName));

                }
                //商城钻石广告
                maiAdInfo.setWatchAdStoreDiamond(getNumber(1000000044,1,time,endTime,sysDictDetail,tableName));
                //失败商城钻石广告
                maiAdInfo.setFailWatchAdStoreDiamond(getNumber(1000000044,0,time,endTime,sysDictDetail,tableName));
                //对局免输广告
                maiAdInfo.setWatchAdLose(getNumber(1000000046,1,time,endTime,sysDictDetail,tableName));
                //失败对局免输广告
                maiAdInfo.setFailWatchAdLose(getNumber(1000000046,0,time,endTime,sysDictDetail,tableName));
                //对局救济金广告
                maiAdInfo.setWatchAdBroke(getNumber(1000000047,1,time,endTime,sysDictDetail,tableName));
                //失败对局救济金广告
                maiAdInfo.setFailWatchAdBroke(getNumber(1000000047,0,time,endTime,sysDictDetail,tableName));
                //转盘广告
                maiAdInfo.setWatchAdHappyLoot(getNumber(1000000048,1,time,endTime,sysDictDetail,tableName));
                //失败转盘广告
                maiAdInfo.setFailWatchAdHappyLoot(getNumber(1000000048,0,time,endTime,sysDictDetail,tableName));
                //7日签到广告
                maiAdInfo.setWatchAdSignSeven(getNumber(1000000050,1,time,endTime,sysDictDetail,tableName));
                //失败7日签到广告
                maiAdInfo.setFailWatchAdSignSeven(getNumber(1000000050,0,time,endTime,sysDictDetail,tableName));
                //好牌开局
                maiAdInfo.setWatchAdGoodCard(getNumber(1000000056,1,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdGoodCard(getNumber(1000000056,0,time,endTime,sysDictDetail,tableName));

                //红中开局
                maiAdInfo.setWatchAdHongzhong(getNumber(1000000057,2,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdHongzhong(getNumber(1000000057,0,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setWatchAdHongzhongjl(getNumber(1000000057,3,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setWatchAdHongzhongbxp(getNumber(1000000057,5,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdHongzhongbxp(getNumber(1000000057,4,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdHongzhongjl(getNumber(1000000057,1,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setWatchAdHongzhongqs(getNumber(1000000057,7,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdHongzhongqs(getNumber(1000000057,6,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setWatchAdHongzhong4(getNumber(1000000057,9,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdHongzhong4(getNumber(1000000057,8,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setWatchAdHongzhongkl(getNumber(1000000057,11,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdHongzhongkl(getNumber(1000000057,10,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setWatchAdHongzhongklqs(getNumber(1000000057,13,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdHongzhongklqs(getNumber(1000000057,12,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setWatchAdHongzhongxl8(getNumber(1000000057,15,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdHongzhongxl8(getNumber(1000000057,14,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setWatchAdQianceng(getNumber(1000000057,17,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdQianceng(getNumber(1000000057,16,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setWatchAdBagang(getNumber(1000000057,19,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdBagang(getNumber(1000000057,18,time,endTime,sysDictDetail,tableName));

                //新用户点击商城
                maiAdInfo.setWatchAdBenefit(getNumber(1000000064,1,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdBenefit(getNumber(1000000064,0,time,endTime,sysDictDetail,tableName));

                maiAdInfo.setMrtWatchAdGoodCard(getNumber(1000000082,1,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailMrtWatchAdGoodCard(getNumber(1000000082,0,time,endTime,sysDictDetail,tableName));

                maiAdInfo.setWatchAdWealthCom(getNumber(1000000104,1,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdWealthCom(getNumber(1000000104,0,time,endTime,sysDictDetail,tableName));

                maiAdInfo.setWatchAdPropsFuka(getNumber(1000000111,3,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdPropsFuka(getNumber(1000000111,0,time,endTime,sysDictDetail,tableName));

                maiAdInfo.setWatchAdPropsFeng(getNumber(1000000111,4,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdPropsFeng(getNumber(1000000111,2,time,endTime,sysDictDetail,tableName));

                maiAdInfo.setWatchAdPropsJia(getNumber(1000000111,5,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdPropsJia(getNumber(1000000111,1,time,endTime,sysDictDetail,tableName));

                maiAdInfo.setWatchAdMatchJoin(getNumber(1000000130,1,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdMatchJoin(getNumber(1000000130,0,time,endTime,sysDictDetail,tableName));
                if(sysDictDetail.getValue().equals("totalcl")||sysDictDetail.getValue().indexOf("cl_")>0) {
                    maiAdInfo.setWatchAdBigOrSmall(getNumber(1000000131, 1, time, endTime, sysDictDetail, tableName));
                    maiAdInfo.setFailWatchAdBigOrSmall(getNumber(1000000131, 0, time, endTime, sysDictDetail, tableName));
                }else {
                    maiAdInfo.setWatchAdBigOrSmall(getNumber(1000000157, 1, time, endTime, sysDictDetail, tableName));
                    maiAdInfo.setFailWatchAdBigOrSmall(getNumber(1000000157, 0, time, endTime, sysDictDetail, tableName));
                }
                maiAdInfo.setWatchAdGodBlessJP(getNumber(1000000160,1,time,endTime,sysDictDetail,tableName));
                maiAdInfo.setFailWatchAdGodBlessJP(getNumber(1000000160,0,time,endTime,sysDictDetail,tableName));

                maiAdInfo.setAllWatch(
                        maiAdInfo.getWatchAdLose()+maiAdInfo.getFailWatchAdLose()+maiAdInfo.getFailWatchAdBroke()+maiAdInfo.getWatchAdHappyLoot()+maiAdInfo.getFailWatchAdHappyLoot()+maiAdInfo.getWatchAdSignSeven()+
                                maiAdInfo.getFailWatchAdSignSeven()+maiAdInfo.getWatchAdGoodCard()+maiAdInfo.getFailWatchAdGoodCard()+maiAdInfo.getWatchAdHongzhong()+maiAdInfo.getFailWatchAdHongzhong()+maiAdInfo.getWatchAdHongzhongjl()+
                                maiAdInfo.getFailWatchAdHongzhongjl()+maiAdInfo.getMrtWatchAdGoodCard()+maiAdInfo.getFailMrtWatchAdGoodCard()+maiAdInfo.getWatchAdMatchJoin()+maiAdInfo.getFailWatchAdMatchJoin()+
                                maiAdInfo.getWatchAdPropsFuka()+maiAdInfo.getFailWatchAdPropsFuka()+maiAdInfo.getWatchAdPropsFeng()+maiAdInfo.getFailWatchAdPropsFeng()+maiAdInfo.getWatchAdPropsJia()+maiAdInfo.getFailWatchAdPropsJia()+
                                maiAdInfo.getWatchAdHongzhong4()+ maiAdInfo.getWatchAdHongzhongqs()+ maiAdInfo.getWatchAdHongzhongkl()+ maiAdInfo.getWatchAdHongzhongklqs()+maiAdInfo.getFailWatchAdHongzhong4()+ maiAdInfo.getFailWatchAdHongzhongqs()+ maiAdInfo.getFailWatchAdHongzhongkl()+ maiAdInfo.getFailWatchAdHongzhongklqs()
                        +maiAdInfo.getWatchAdBigOrSmall()+maiAdInfo.getFailWatchAdBigOrSmall()+maiAdInfo.getWatchAdGodBlessJP()+maiAdInfo.getFailWatchAdGodBlessJP()+maiAdInfo.getWatchAdQianceng()+maiAdInfo.getFailWatchAdQianceng()+maiAdInfo.getFailWatchAdBagang()+maiAdInfo.getWatchAdBagang()
                );
                maiAdInfo.setAllAcWatch(
                        maiAdInfo.getWatchAdLose()+maiAdInfo.getWatchAdHappyLoot()+maiAdInfo.getWatchAdSignSeven()+ maiAdInfo.getWatchAdHongzhong4()+ maiAdInfo.getWatchAdHongzhongqs()+ maiAdInfo.getWatchAdHongzhongkl()+ maiAdInfo.getWatchAdHongzhongklqs()+
                                maiAdInfo.getWatchAdGoodCard()+maiAdInfo.getWatchAdHongzhong()+maiAdInfo.getWatchAdHongzhongjl()+maiAdInfo.getMrtWatchAdGoodCard()+maiAdInfo.getWatchAdPropsFuka()+maiAdInfo.getWatchAdPropsFeng()+maiAdInfo.getWatchAdPropsJia()+
                                maiAdInfo.getWatchAdMatchJoin()+maiAdInfo.getWatchAdBigOrSmall()+maiAdInfo.getWatchAdGodBlessJP()+maiAdInfo.getWatchAdQianceng()+maiAdInfo.getWatchAdBagang()
                );
                long total=0;
                if(sysDictDetail.getDictSort()==987){
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")||sysDictDetail.getValue().equals("h5gdmjxl_wechat")||sysDictDetail.getValue().equals("h5hcmjxl_wechat")){
                        total = mongoT.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("invite.channel").is("").and("channel").is(sysDictDetail.getValue())), UserEntity.class);
                    }else {

                        total = mongoT.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("invite.channel").is(sysDictDetail.getValue())), UserEntity.class);

                    }
                }else if(sysDictDetail.getDictSort()==900){
                    total = mongoT.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("channel").regex(sysDictDetail.getValue().split("_")[0])), UserEntity.class);
                }else if(sysDictDetail.getDictSort()==910){
                    total = fiveMongoTemplate.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("channel").regex(sysDictDetail.getValue().split("_")[0])), UserEntity.class);
                }else if(sysDictDetail.getDictSort()==920){
                    total = ninethMongoTemplate.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("channel").regex(sysDictDetail.getValue().split("_")[0])), UserEntity.class);
                }
                else if(sysDictDetail.getDictSort()==999) {
                    if(sysDictDetail.getValue().equals("total")) {
                        total = mongoT.count(new Query(Criteria.where("last_time").gte(time).lte(endTime)), UserEntity.class);
                    }else if(sysDictDetail.getValue().equals("totalapp")){
                        total =ninethMongoTemplate.count(new Query(Criteria.where("last_time").gte(time).lte(endTime)), UserEntity.class);
                    }else{
                        total =fiveMongoTemplate.count(new Query(Criteria.where("last_time").gte(time).lte(endTime)), UserEntity.class);
                    }
                }
                else {
                    total = mongoT.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("channel").is(sysDictDetail.getValue())), UserEntity.class);

                }
                maiAdInfo.setActNum(total);

                QueryWrapper<MaiAdInfo> wrapper=new QueryWrapper<>();
                wrapper.eq("time",time);
                wrapper.eq("channel",maiAdInfo.getChannel());
                if(StringUtils.isNotEmpty(maiAdInfo.getTheFather())){
                    wrapper.eq("the_father",maiAdInfo.getTheFather());
                }
                MaiAdInfo maiAdInfo1= maiAdInfoMapper.selectOne(wrapper);
                if(maiAdInfo1==null) {
                    maiAdInfoMapper.insert(maiAdInfo);
                }else {
                    maiAdInfoMapper.update(maiAdInfo,wrapper);
                }
            }
        }
    }

    public Long getNumber(Integer evid,Integer value,Long time,Long endTime,SysDictDetail sysDictDetail,String tableName){
        Criteria criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(evid);
        criteria.and("value").is(value);
        if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
            if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")||sysDictDetail.getValue().equals("h5gdmjxl_wechat")||sysDictDetail.getValue().equals("h5hcmjxl_wechat")){
                criteria.and("channel").is(sysDictDetail.getValue());
                criteria.orOperator(Criteria.where("invite_channel").exists(false),Criteria.where("invite_channel").is(""));
            }
            else {
                criteria.and("invite_channel").is(sysDictDetail.getValue());
            }
        } else if(sysDictDetail.getDictSort() != 99){
            if(sysDictDetail.getDictSort()==900||sysDictDetail.getDictSort()==910){
                criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
            } else {
                criteria.and("channel").is(sysDictDetail.getValue());
            }
        }
        Aggregation aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );

//        System.out.println("criteria is ============= "+new Query().addCriteria(criteria));
//        System.out.println(tableName);
        AggregationResults<TaskEntity> ar;
        if(sysDictDetail.getValue().equals("totalcl")||sysDictDetail.getValue().indexOf("cl_")>0){
            ar = sixthMongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        }else if(sysDictDetail.getValue().equals("totalapp")||(sysDictDetail.getValue().indexOf("gdmj")==0&&sysDictDetail.getDictSort()!=900&&sysDictDetail.getDictSort()!=910)){
            ar = tenthMongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        }
        else {
            ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        }
        List<TaskEntity> list = ar.getMappedResults();
//        System.out.println("list is =============="+list);
        if (list.size() > 0) {
           return list.get(0).getNum();
        }
        return 0l;
    }

    public Long getbodyNumber(Integer evid,Integer value,Long time,Long endTime,SysDictDetail sysDictDetail,String tableName,String[] userId){
        Criteria criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(evid);
        criteria.and("value").is(value);
        criteria.and("numid").in(userId);
        if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
            if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")||sysDictDetail.getValue().equals("h5gdmjxl_wechat")||sysDictDetail.getValue().equals("h5hcmjxl_wechat")){
                criteria.and("channel").is(sysDictDetail.getValue());
                criteria.orOperator(Criteria.where("invite_channel").exists(false),Criteria.where("invite_channel").is(""));
            }
            else {
                criteria.and("invite_channel").is(sysDictDetail.getValue());
            }
        } else if(sysDictDetail.getDictSort() != 99){
            if(sysDictDetail.getDictSort()==900||sysDictDetail.getDictSort()==910){
                criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
            } else {
                criteria.and("channel").is(sysDictDetail.getValue());
            }
        }
        Aggregation aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );

//        System.out.println("criteria is ============= "+new Query().addCriteria(criteria));
//        System.out.println(tableName);
        AggregationResults<TaskEntity> ar;
        if(sysDictDetail.getValue().equals("totalcl")||sysDictDetail.getValue().indexOf("cl_")>0){
            ar = sixthMongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        }else {
            ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        }
        List<TaskEntity> list = ar.getMappedResults();
//        System.out.println("list is =============="+list);
        if (list.size() > 0) {
            return list.get(0).getNum();
        }
        return 0l;
    }

    public void recordShareByChannel(long time,long endTime,String tab) {
        String regTable="register_rec_"+tab;
        String tableName="collect_data_"+tab;
        QueryWrapper<SysDictDetail> wrapper1=new QueryWrapper<>();
        wrapper1.eq("dict_id",16);
        wrapper1.le("dict_sort",988);
        wrapper1.orderByDesc("dict_sort");
        List<SysDictDetail> list1=sysDictDetailMapper.selectList(wrapper1);
        SysDictDetail sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("total");
        sysDictDetail1.setDictSort(999);
        list1.add(sysDictDetail1);
        sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("totalcl");
        sysDictDetail1.setDictSort(999);
        list1.add(sysDictDetail1);
        sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("totalapp");
        sysDictDetail1.setDictSort(999);
        list1.add(sysDictDetail1);
        if(list1.size()>0){
            for (SysDictDetail sysDictDetail:list1) {
                MaiShareInfo maiShareInfo = new MaiShareInfo();
                maiShareInfo.setChannel(sysDictDetail.getValue());
                maiShareInfo.setTime((int) time);
                if(sysDictDetail.getValue().equals("total")||sysDictDetail.getValue().equals("totalcl")){}else{
                    if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==987) {
                        if(sysDictDetail.getValue().equals("qq_share")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                            maiShareInfo.setTheFather("h5hzmjxl_qq");
                        }else if(sysDictDetail.getValue().indexOf("gdmj")>-1){
                            maiShareInfo.setTheFather("h5gdmjxl_wechat");
                        }else if(sysDictDetail.getValue().indexOf("hcmj")>-1){
                            maiShareInfo.setTheFather("h5hcmjxl_wechat");
                        }else {
                            maiShareInfo.setTheFather("h5hzmjxl_wechat");
                        }
                    }else if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==900) {
                        maiShareInfo.setTheFather("total");
                    }else if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==910) {
                        maiShareInfo.setTheFather("totalcl");
                    }else if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==920) {
                        maiShareInfo.setTheFather("totalapp");
                    }
                    else {
                        if(sysDictDetail.getValue().equals("h5zhsmjcl_wechat")){
                            maiShareInfo.setTheFather("zsmjxl_total");
                        }else if(sysDictDetail.getValue().indexOf("h5")==-1&&sysDictDetail.getValue().indexOf("gdmj")==0){
                            maiShareInfo.setTheFather(sysDictDetail.getValue().split("_")[0] + "_app_total");
                        }else {
                            maiShareInfo.setTheFather(sysDictDetail.getValue().split("_")[0].replace("h5", "") + "_total");
                        }
                    }
                }

                //受邀请者总数
                Criteria criteria = new Criteria();
                criteria.and("unix_time").gte(time).lte(endTime);
                criteria.and("invite_extra").exists(true);
                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")||sysDictDetail.getValue().equals("h5gdmjxl_wechat")||sysDictDetail.getValue().equals("h5hcmjxl_wechat")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("invite_channel").exists(false),Criteria.where("invite_channel").is(""));
                    }
                    else {
                        criteria.and("invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 999){
                    if(sysDictDetail.getDictSort()==900||sysDictDetail.getDictSort()==910||sysDictDetail.getDictSort()==920){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
               Aggregation aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("id").count().as("num"),
                        Aggregation.group().sum("num").as("num")
                );
                AggregationResults<TaskEntity> ar ;
                if(sysDictDetail.getValue().equals("totalcl")||sysDictDetail.getValue().indexOf("cl_")>0){
                    ar = mongoTemplate.aggregate(aggregation, regTable, TaskEntity.class);
                }
                else {
                    ar = mongoTemplate.aggregate(aggregation, regTable, TaskEntity.class);
                }

                List<TaskEntity> list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiShareInfo.setBeInvite(list.get(0).getNum());
                }

                //总邀请次数
                Object evids[]=new Object[]{1000000066,1000000067,1000000068,1000000069,1000000070,1000000071,1000000072,1000000073,1000000074,1000000075,1000000076,1000000077,1000000078,1000000079,1000000080,1000000083,1000000084};

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").in(evids);
//                criteria.and("value").is(1);
                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")||sysDictDetail.getValue().equals("h5gdmjxl_wechat")||sysDictDetail.getValue().equals("h5hcmjxl_wechat")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("invite_channel").exists(false),Criteria.where("invite_channel").is(""));
                    }
                    else {
                        criteria.and("invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900||sysDictDetail.getDictSort()==910){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("num"),
                        Aggregation.group("numid").count().as("num")

                );
                if(sysDictDetail.getValue().equals("totalcl")||sysDictDetail.getValue().indexOf("cl_")>0){
                    ar = sixthMongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                }else if(sysDictDetail.getValue().equals("totalapp")||(sysDictDetail.getValue().indexOf("gdmj")==0&&sysDictDetail.getDictSort()!=900&&sysDictDetail.getDictSort()!=910)){
                    ar = tenthMongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                }
                else {
                    ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                }
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiShareInfo.setInvite( list.get(0).getNum());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").in(evids);
//                criteria.and("value").is(1);
                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")||sysDictDetail.getValue().equals("h5gdmjxl_wechat")||sysDictDetail.getValue().equals("h5hcmjxl_wechat")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("invite_channel").exists(false),Criteria.where("invite_channel").is(""));
                    }
                    else {
                        criteria.and("invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num"),
                        Aggregation.group().sum("num").as("num")
                );
                if(sysDictDetail.getValue().equals("totalcl")||sysDictDetail.getValue().indexOf("cl_")>0){
                    ar = sixthMongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                }else if(sysDictDetail.getValue().equals("totalapp")||(sysDictDetail.getValue().indexOf("gdmj")==0&&sysDictDetail.getDictSort()!=900&&sysDictDetail.getDictSort()!=910)){
                    ar = tenthMongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                }
                else {
                    ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                }

                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiShareInfo.setInvites(list.get(0).getNum());
                }
                //商城钻石分享
                maiShareInfo.setShareStoreDiamond(getNumber(1000000066,1,time,endTime,sysDictDetail,tableName));
                //失败商城钻石分享
                maiShareInfo.setFailShareStoreDiamond(getNumber(1000000066,0,time,endTime,sysDictDetail,tableName));

                maiShareInfo.setShareLose(getNumber(1000000068,1,time,endTime,sysDictDetail,tableName));
                //失败商城钻石分享
                maiShareInfo.setFailShareLose(getNumber(1000000068,0,time,endTime,sysDictDetail,tableName));

                maiShareInfo.setShareBroke(getNumber(1000000069,1,time,endTime,sysDictDetail,tableName));
                //失败商城钻石分享
                maiShareInfo.setFailShareBroke(getNumber(1000000069,0,time,endTime,sysDictDetail,tableName));

                maiShareInfo.setShareHappyLoot(getNumber(1000000070,1,time,endTime,sysDictDetail,tableName));
                //失败商城钻石分享
                maiShareInfo.setFailShareHappyLoot(getNumber(1000000070,0,time,endTime,sysDictDetail,tableName));

                maiShareInfo.setShareSignSeven(getNumber(1000000072,1,time,endTime,sysDictDetail,tableName));
                //失败商城钻石分享
                maiShareInfo.setFailShareSignSeven(getNumber(1000000072,0,time,endTime,sysDictDetail,tableName));

                maiShareInfo.setShareResult(getNumber(1000000080,1,time,endTime,sysDictDetail,tableName));
                //失败商城钻石分享
                maiShareInfo.setFailShareResult(getNumber(1000000080,0,time,endTime,sysDictDetail,tableName));

                maiShareInfo.setShareInvite(getNumber(1000000084,1,time,endTime,sysDictDetail,tableName));
                //失败商城钻石分享
                maiShareInfo.setFailShareInvite(getNumber(1000000084,0,time,endTime,sysDictDetail,tableName));

                QueryWrapper<MaiShareInfo> wrapper2=new QueryWrapper<>();
                wrapper2.eq("time",time);
                wrapper2.eq("channel",maiShareInfo.getChannel());
                if(StringUtils.isNotEmpty(maiShareInfo.getTheFather())){
                    wrapper2.eq("the_father",maiShareInfo.getTheFather());
                }

                MaiShareInfo maiShareInfo1= maiShareInfoMapper.selectOne(wrapper2);
                if(maiShareInfo1==null) {
                    maiShareInfoMapper.insert(maiShareInfo);
                }else {
                    maiShareInfoMapper.update(maiShareInfo,wrapper2);
                }

            }
        }
    }

    public void record(long time,long endTime,String tab){

        String tableName;
        tableName="collect_data_"+tab;
        MaiInfo maiInfo=new MaiInfo();
        maiInfo.setTime((int)time);
        maiInfo.setChannel("total");
        //新用户登陆
        Criteria criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000003);
        Aggregation aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("dev").count().as("num")
        );
        AggregationResults<TaskEntity>  ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        List<TaskEntity> list = ar.getMappedResults();
        if(list.size()>0){
          maiInfo.setEnterLoginScene((long)list.size());
        }

        //新用户点击登录
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000004);
        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("dev").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickLogin((long)list.size());
        }

        //新用户点击个人信息
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000005);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("numid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setEnterMainScene((long)list.size());
        }


        //新用户点击个人信息
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000006);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();

        if(list.size()>0){
            maiInfo.setClickRoleInfo(list.get(0).getNum());
        }

        //新用户点击实名认证
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000007);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickRealName(list.get(0).getNum());
        }




        //新用户点击嘻嘻币+
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000008);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickXixibiAdd(list.get(0).getNum());
        }
        //新用户点击钻石+
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000009);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickDiamondAdd(list.get(0).getNum());
        }
        //新用户点击邮件
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000010);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickEMail(list.get(0).getNum());
        }

        //新用户点击设置
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000011);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickSetting(list.get(0).getNum());
        }

        //新用户点击排行榜
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000012);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickRanking(list.get(0).getNum());
        }

        //新用户点击商城
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000013);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickStore(list.get(0).getNum());
        }

        //新用户点击背包
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000014);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickBag(list.get(0).getNum());
        }
        //新用户点击活动
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000015);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickActivity(list.get(0).getNum());
        }

        //新用户点击任务
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000016);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickTask(list.get(0).getNum());
        }


        //新用户点击存币
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000017);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickBank(list.get(0).getNum());
        }



        //新用户点击帮助
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000018);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickHelp(list.get(0).getNum());
        }




        //新用户点击对局宝箱
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000108);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickRewardBox(list.get(0).getNum());
        }


        //新用户点击财神降临
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000025);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickWealthCome(list.get(0).getNum());
        }


        //新用户点击免费钻石
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000026);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickFreeDiamond(list.get(0).getNum());
        }





        //新用户点击商城
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000065);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickMonthCard(list.get(0).getNum());
        }

        //新用户点击商城
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000061);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("numid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setSaveToDesktop((long)list.size());
        }
        criteria.and("value").is(1);
        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("numid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setSaveToDesktopOk((long)list.size());
        }

        //新用户点击商城
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000062);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("numid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setAddColorSign((long)list.size());
        }
        criteria.and("value").is(1);
        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("numid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setAddColorSignOk((long)list.size());
        }

        //用户点击游戏内存钱罐
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000091);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickFightSav(list.get(0).getNum());
        }

        //用户点击存钱罐
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000106);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickMainSav(list.get(0).getNum());
        }


        //用户点击客服
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000096);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickService(list.get(0).getNum());
        }

        //用户点击客服
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000097);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setEnterByDesk(list.get(0).getNum());
        }

        //用户点击客服
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000098);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setEnterByApp(list.get(0).getNum());
        }

        //用户点击新月卡
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000110);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickShakeSticks(list.get(0).getNum());
        }

        //用户点击新月卡
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000112);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickNewMonthCard(list.get(0).getNum());
        }

        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000113);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickInviteReward(list.get(0).getNum());
        }

        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000114);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickLive(list.get(0).getNum());
        }

        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000115);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickCdkAward(list.get(0).getNum());
        }

        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000116);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickSaveToDesktop(list.get(0).getNum());
        }

        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000117);


        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiInfo.setClickCollection(list.get(0).getNum());
        }


        QueryWrapper<MaiInfo> wrapper=new QueryWrapper<>();
        wrapper.eq("time",maiInfo.getTime());
        maiInfoMapper.delete(wrapper);
        maiInfoMapper.insert(maiInfo);
        System.out.println(maiInfo);
    }

    public void recordByChannel(long time,long endTime,String tab){

        String tableName="collect_data_"+tab;
        QueryWrapper<SysDictDetail> wrapper1=new QueryWrapper<>();
        wrapper1.eq("dict_id",16);
        wrapper1.le("dict_sort",20).or().eq("dict_sort",987).or().eq("dict_sort",900);
        wrapper1.orderByDesc("dict_sort");
        List<SysDictDetail> list1=sysDictDetailMapper.selectList(wrapper1);
        SysDictDetail sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("h5hzmjxl_wechat");
        sysDictDetail1.setDictSort(987);
        list1.add(sysDictDetail1);
        sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("h5hzmjxl_qq");
        sysDictDetail1.setDictSort(987);
        list1.add(sysDictDetail1);
        sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("total");
        sysDictDetail1.setDictSort(99);
        list1.add(sysDictDetail1);
        if(list1.size()>0){
            for (SysDictDetail sysDictDetail:list1) {
                MaiInfo maiInfo=new MaiInfo();
                maiInfo.setChannel(sysDictDetail.getValue());
                maiInfo.setTime((int) time);
                if(!sysDictDetail.getValue().equals("total")){
                if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==987) {
                    if(sysDictDetail.getValue().equals("qq_share")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        maiInfo.setTheFather("h5hzmjxl_qq");
                    }else {
                        maiInfo.setTheFather("h5hzmjxl_wechat");
                    }
                }else if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==900) {
                       maiInfo.setTheFather("total");
                }
                else {
                    maiInfo.setTheFather(sysDictDetail.getValue().split("_")[0].replace("h5","")+"_total");
                }
                }
                //新用户登陆
                Criteria criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000003);
                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                Aggregation aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("dev").count().as("num")
                );
                AggregationResults<TaskEntity> ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                List<TaskEntity> list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setEnterLoginScene((long) list.size());
                }

                //新用户点击登录
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000004);
                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("dev").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickLogin((long) list.size());
                }

                //新用户点击个人信息
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000005);


                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setEnterMainScene((long) list.size());
                }


                //新用户点击个人信息
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000006);


                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();

                if (list.size() > 0) {
                    maiInfo.setClickRoleInfo(list.get(0).getNum());
                }

                //新用户点击实名认证
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000007);


                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickRealName(list.get(0).getNum());
                }


                //新用户点击嘻嘻币+
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000008);


                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickXixibiAdd(list.get(0).getNum());
                }
                //新用户点击钻石+
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000009);


                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickDiamondAdd(list.get(0).getNum());
                }
                //新用户点击邮件
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000010);


                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickEMail(list.get(0).getNum());
                }

                //新用户点击设置
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000011);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickSetting(list.get(0).getNum());
                }


                //新用户点击排行榜
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000012);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickRanking(list.get(0).getNum());
                }


                //新用户点击商城
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000013);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickStore(list.get(0).getNum());
                }


                //新用户点击背包
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000014);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickBag(list.get(0).getNum());
                }


                //新用户点击活动
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000015);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickActivity(list.get(0).getNum());
                }


                //新用户点击任务
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000016);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickTask(list.get(0).getNum());
                }


                //新用户点击存币
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000017);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickBank(list.get(0).getNum());
                }


                //新用户点击帮助
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000018);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickHelp(list.get(0).getNum());
                }


                //新用户点击对局宝箱
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000108);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickRewardBox(list.get(0).getNum());
                }




                //新用户点击财神降临
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000025);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickWealthCome(list.get(0).getNum());
                }


                //新用户点击免费钻石
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000026);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickFreeDiamond(list.get(0).getNum());
                }

                //新用户点击商城
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000065);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setClickMonthCard(list.get(0).getNum());
                }

                //新用户点击商城
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000061);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setSaveToDesktop((long) list.size());
                }
                criteria.and("value").is(1);
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setSaveToDesktopOk((long) list.size());
                }

                //新用户点击商城
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000062);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setAddColorSign((long) list.size());
                }
                criteria.and("value").is(1);
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    maiInfo.setAddColorSignOk((long) list.size());
                }


                //用户点击游戏内存钱罐
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000091);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setClickFightSav(list.get(0).getNum());
                }

                //用户点击存钱罐
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000106);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setClickMainSav(list.get(0).getNum());
                }


                //用户点击客服
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000096);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setClickService(list.get(0).getNum());
                }

                //用户点击客服
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000097);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setEnterByDesk(list.get(0).getNum());
                }

                //用户点击客服
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000098);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setEnterByApp(list.get(0).getNum());
                }

                //用户点击新月卡
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000112);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setClickNewMonthCard(list.get(0).getNum());
                }

                //用户点击新月卡
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000110);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setClickShakeSticks(list.get(0).getNum());
                }



                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000113);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setClickInviteReward(list.get(0).getNum());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000114);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setClickLive(list.get(0).getNum());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000115);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setClickCdkAward(list.get(0).getNum());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000116);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setClickSaveToDesktop(list.get(0).getNum());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000117);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiInfo.setClickCollection(list.get(0).getNum());
                }
                QueryWrapper<MaiInfo> wrapper=new QueryWrapper<>();
                wrapper.eq("time",time);
                wrapper.eq("channel",maiInfo.getChannel());
                if(StringUtils.isNotEmpty(maiInfo.getTheFather())){
                    wrapper.eq("the_father",maiInfo.getTheFather());
                }
                MaiInfo maiInfo1= maiInfoMapper.selectOne(wrapper);
                if(maiInfo1==null) {
                    maiInfoMapper.insert(maiInfo);
                }else {
                    maiInfoMapper.update(maiInfo,wrapper);
                }

            }
        }
    }

    public void recordRooms(long time,long endTime,String tab){
        String tableName="collect_data_" + tab;
        MaiRoomsInfo maiRoomsInfo=new MaiRoomsInfo();
        maiRoomsInfo.setTime((int)time);
        maiRoomsInfo.setChannel("total");
        //新用户点击主界面快速开始
        Criteria criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000019);
        criteria.and("regtime").gte(time-72*3600);

        Aggregation aggregation = Aggregation.newAggregation(
                Aggregation.lookup("user","numid","id","taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        AggregationResults<TaskEntity>  ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        List<TaskEntity> list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickMainQuickStart(list.get(0).getNum());
        }

        //老用户点击主界面快速开始
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000019);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickMainQuickStart(list.get(0).getNum());
        }

        //新用户点击二级界面快速开始
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000043);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickRoomQuickStart(list.get(0).getNum());
        }

        //老用户点击二级界面快速开始
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000043);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickRoomQuickStart(list.get(0).getNum());
        }

        //新用户点击红中血流
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000020);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzxl(list.get(0).getNum());
        }

        //老用户点击红中血流
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000020);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzxl(list.get(0).getNum());
        }

        //新用户点击6红中血流
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000021);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzx6(list.get(0).getNum());
        }

        //老用户点击6红中血流
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000021);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzx6(list.get(0).getNum());
        }

        //新用户点击名人堂
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000022);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestige(list.get(0).getNum());
        }

        //老用户点击名人堂
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000022);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestige(list.get(0).getNum());
        }
        //新用户点击红中血流菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000030);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzxlCainiao(list.get(0).getNum());
        }

        //老用户点击红中血流菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000030);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzxlCainiao(list.get(0).getNum());
        }
        //新用户点击红中血流平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000031);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzxlPingmin(list.get(0).getNum());
        }

        //老用户点击红中血流平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000031);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzxlPingmin(list.get(0).getNum());
        }
        //新用户点击红中血流土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000032);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzxlTuhao(list.get(0).getNum());
        }

        //老用户点击红中血流土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000032);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzxlTuhao(list.get(0).getNum());
        }
        //新用户点击红中血流巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000033);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzxlJufu(list.get(0).getNum());
        }

        //老用户点击红中血流巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000033);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzxlJufu(list.get(0).getNum());
        }
        //新用户点击雀神名人堂菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000034);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestigeCainiao(list.get(0).getNum());
        }

        //老用户点击雀神名人堂菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000034);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestigeCainiao(list.get(0).getNum());
        }
        //新用户点击雀神名人堂平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000035);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestigePingmin(list.get(0).getNum());
        }

        //老用户点击雀神名人堂平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000035);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestigePingmin(list.get(0).getNum());
        }
        //新用户点击雀神名人堂土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000036);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestigeTuhao(list.get(0).getNum());
        }

        //老用户点击雀神名人堂土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000036);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestigeTuhao(list.get(0).getNum());
        }
        //新用户点击雀神名人堂巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000037);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestigeJufu(list.get(0).getNum());
        }

        //老用户点击雀神名人堂巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000037);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestigeJufu(list.get(0).getNum());
        }
        //新用户点击雀神名人堂免费场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000038);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestigeFree(list.get(0).getNum());
        }

        //老用户点击雀神名人堂免费场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000038);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestigeFree(list.get(0).getNum());
        }
        //新用户点击6红中血流菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000039);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzx6Cainiao(list.get(0).getNum());
        }

        //老用户点击6红中血流菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000039);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzx6Cainiao(list.get(0).getNum());
        }
        //新用户点击6红中血流平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000040);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzx6Pingmin(list.get(0).getNum());
        }

        //老用户点击6红中血流平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000040);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzx6Pingmin(list.get(0).getNum());
        }
        //新用户点击6红中血流土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000041);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzx6Tuhao(list.get(0).getNum());
        }

        //老用户点击6红中血流土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000041);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzx6Tuhao(list.get(0).getNum());
        }
        //新用户点击6红中血流巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000042);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzx6Jufu(list.get(0).getNum());
        }

        //老用户点击6红中血流巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000042);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzx6Jufu(list.get(0).getNum());
        }

        //新用户点击红中接力
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000099);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickXljl(list.get(0).getNum());
        }

        //老用户点击红中接力
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000099);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickXljl(list.get(0).getNum());
        }

        //新用户点击红中接力菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000100);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickXljlCainiao(list.get(0).getNum());
        }

        //老用户点击红中接力菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000100);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickXljlCainiao(list.get(0).getNum());
        }

        //新用户点击红中接力平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000101);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickXljlPingmin(list.get(0).getNum());
        }

        //老用户点击红中接力平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000101);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickXljlPingmin(list.get(0).getNum());
        }

        //新用户点击红中接力土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000102);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickXljlTuhao(list.get(0).getNum());
        }

        //老用户点击红中接力土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000102);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickXljlTuhao(list.get(0).getNum());
        }

        //新用户点击红中接力巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000103);
        criteria.and("regtime").gte(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickXljlJufu(list.get(0).getNum());
        }

        //老用户点击红中接力巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000103);
        criteria.and("regtime").lt(time-72*3600);

        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickXljlJufu(list.get(0).getNum());
        }
        QueryWrapper<MaiRoomsInfo> wrapper=new QueryWrapper<>();
        wrapper.eq("time",maiRoomsInfo.getTime());
        maiRoomsInfoMapper.delete(wrapper);
        maiRoomsInfoMapper.insert(maiRoomsInfo);
    }

    public void recordRoomsByChannel(long time,long endTime,String tab){

        String tableName="collect_data_"+tab;
        QueryWrapper<SysDictDetail> wrapper1=new QueryWrapper<>();
        wrapper1.eq("dict_id",16);
        wrapper1.le("dict_sort",20).or().eq("dict_sort",987).or().eq("dict_sort",900);
        wrapper1.orderByDesc("dict_sort");
        List<SysDictDetail> list1=sysDictDetailMapper.selectList(wrapper1);
        SysDictDetail sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("h5hzmjxl_wechat");
        sysDictDetail1.setDictSort(987);
        list1.add(sysDictDetail1);
        sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("h5hzmjxl_qq");
        sysDictDetail1.setDictSort(987);
        list1.add(sysDictDetail1);
        sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("total");
        sysDictDetail1.setDictSort(99);
        list1.add(sysDictDetail1);
        if(list1.size()>0){
            for (SysDictDetail sysDictDetail:list1) {
                MaiRoomsInfo maiRoomsInfo=new MaiRoomsInfo();
                maiRoomsInfo.setChannel(sysDictDetail.getValue());
                maiRoomsInfo.setTime((int) time);
                if(!sysDictDetail.getValue().equals("total")){
                    if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==987) {
                        if(sysDictDetail.getValue().equals("qq_share")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                            maiRoomsInfo.setTheFather("h5hzmjxl_qq");
                        }else {
                            maiRoomsInfo.setTheFather("h5hzmjxl_wechat");
                        }
                    }else if(sysDictDetail.getDictSort()!=null&&sysDictDetail.getDictSort()==900) {
                        maiRoomsInfo.setTheFather("total");
                    }
                    else {
                        maiRoomsInfo.setTheFather(sysDictDetail.getValue().split("_")[0].replace("h5","")+"_total");
                    }
                }
        //新用户点击主界面快速开始
        Criteria criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000019);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                Aggregation aggregation = Aggregation.newAggregation(
                 Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        AggregationResults<TaskEntity>  ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        List<TaskEntity> list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickMainQuickStart(list.get(0).getNum());
        }

        //老用户点击主界面快速开始
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000019);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickMainQuickStart(list.get(0).getNum());
        }

        //新用户点击二级界面快速开始
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000043);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickRoomQuickStart(list.get(0).getNum());
        }

        //老用户点击二级界面快速开始
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000043);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickRoomQuickStart(list.get(0).getNum());
        }

        //新用户点击红中血流
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000020);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzxl(list.get(0).getNum());
        }

        //老用户点击红中血流
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000020);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzxl(list.get(0).getNum());
        }

        //新用户点击6红中血流
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000021);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzx6(list.get(0).getNum());
        }

        //老用户点击6红中血流
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000021);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzx6(list.get(0).getNum());
        }

        //新用户点击名人堂
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000022);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestige(list.get(0).getNum());
        }

        //老用户点击名人堂
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000022);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestige(list.get(0).getNum());
        }
        //新用户点击红中血流菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000030);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzxlCainiao(list.get(0).getNum());
        }

        //老用户点击红中血流菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000030);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzxlCainiao(list.get(0).getNum());
        }
        //新用户点击红中血流平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000031);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzxlPingmin(list.get(0).getNum());
        }

        //老用户点击红中血流平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000031);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzxlPingmin(list.get(0).getNum());
        }
        //新用户点击红中血流土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000032);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzxlTuhao(list.get(0).getNum());
        }

        //老用户点击红中血流土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000032);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzxlTuhao(list.get(0).getNum());
        }
        //新用户点击红中血流巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000033);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzxlJufu(list.get(0).getNum());
        }

        //老用户点击红中血流巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000033);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzxlJufu(list.get(0).getNum());
        }
        //新用户点击雀神名人堂菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000034);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestigeCainiao(list.get(0).getNum());
        }

        //老用户点击雀神名人堂菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000034);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestigeCainiao(list.get(0).getNum());
        }
        //新用户点击雀神名人堂平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000035);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestigePingmin(list.get(0).getNum());
        }

        //老用户点击雀神名人堂平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000035);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestigePingmin(list.get(0).getNum());
        }
        //新用户点击雀神名人堂土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000036);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestigeTuhao(list.get(0).getNum());
        }

        //老用户点击雀神名人堂土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000036);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestigeTuhao(list.get(0).getNum());
        }
        //新用户点击雀神名人堂巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000037);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestigeJufu(list.get(0).getNum());
        }

        //老用户点击雀神名人堂巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000037);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestigeJufu(list.get(0).getNum());
        }
        //新用户点击雀神名人堂免费场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000038);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickPrestigeFree(list.get(0).getNum());
        }

        //老用户点击雀神名人堂免费场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000038);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickPrestigeFree(list.get(0).getNum());
        }
        //新用户点击6红中血流菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000039);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzx6Cainiao(list.get(0).getNum());
        }

        //老用户点击6红中血流菜鸟场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000039);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzx6Cainiao(list.get(0).getNum());
        }
        //新用户点击6红中血流平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000040);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzx6Pingmin(list.get(0).getNum());
        }

        //老用户点击6红中血流平民场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000040);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzx6Pingmin(list.get(0).getNum());
        }
        //新用户点击6红中血流土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000041);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzx6Tuhao(list.get(0).getNum());
        }

        //老用户点击6红中血流土豪场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000041);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzx6Tuhao(list.get(0).getNum());
        }
        //新用户点击6红中血流巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000042);
        criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setClickHzx6Jufu(list.get(0).getNum());
        }

        //老用户点击6红中血流巨富场
        criteria = new Criteria();
        criteria.and("time").gte(time).lte(endTime);
        criteria.and("evid").is(1000000042);
        criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                Aggregation.match(criteria),
                Aggregation.group("evid").count().as("num")
        );
        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
        list = ar.getMappedResults();
        if(list.size()>0){
            maiRoomsInfo.setOldClickHzx6Jufu(list.get(0).getNum());
        }

                //新用户点击红中接力
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000099);
                criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiRoomsInfo.setClickXljl(list.get(0).getNum());
                }

                //老用户点击红中接力
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000099);
                criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiRoomsInfo.setOldClickXljl(list.get(0).getNum());
                }

                //新用户点击红中接力菜鸟场
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000100);
                criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiRoomsInfo.setClickXljlCainiao(list.get(0).getNum());
                }

                //老用户点击红中接力菜鸟场
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000100);
                criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiRoomsInfo.setOldClickXljlCainiao(list.get(0).getNum());
                }

                //新用户点击红中接力平民场
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000101);
                criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiRoomsInfo.setClickXljlPingmin(list.get(0).getNum());
                }

                //老用户点击红中接力平民场
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000101);
                criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiRoomsInfo.setOldClickXljlPingmin(list.get(0).getNum());
                }

                //新用户点击红中接力土豪场
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000102);
                criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiRoomsInfo.setClickXljlTuhao(list.get(0).getNum());
                }

                //老用户点击红中接力土豪场
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000102);
                criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiRoomsInfo.setOldClickXljlTuhao(list.get(0).getNum());
                }

                //新用户点击红中接力巨富场
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000103);
                criteria.and("regtime").gte(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiRoomsInfo.setClickXljlJufu(list.get(0).getNum());
                }

                //老用户点击红中接力巨富场
                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000103);
                criteria.and("regtime").lt(time-72*3600);

                if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                    if(sysDictDetail.getValue().equals("h5hzmjxl_wechat")||sysDictDetail.getValue().equals("h5hzmjxl_qq")){
                        criteria.and("channel").is(sysDictDetail.getValue());
                        criteria.orOperator(Criteria.where("taskUser.invite_channel").exists(false),Criteria.where("taskUser.invite_channel").is(""));
                    }
                    else {
                        criteria.and("taskUser.invite_channel").is(sysDictDetail.getValue());
                    }
                } else if(sysDictDetail.getDictSort() != 99){
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.lookup("register_rec", "numid", "id", "taskUser"),
                        Aggregation.match(criteria),
                        Aggregation.group("evid").count().as("num")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                list = ar.getMappedResults();
                if(list.size()>0){
                    maiRoomsInfo.setOldClickXljlJufu(list.get(0).getNum());
                }
                QueryWrapper<MaiRoomsInfo> wrapper=new QueryWrapper<>();
                wrapper.eq("time",time);
                wrapper.eq("channel",maiRoomsInfo.getChannel());
                if(StringUtils.isNotEmpty(maiRoomsInfo.getTheFather())){
                    wrapper.eq("the_father",maiRoomsInfo.getTheFather());
                }
                MaiRoomsInfo maiRoomsInfo1= maiRoomsInfoMapper.selectOne(wrapper);
                if(maiRoomsInfo1==null) {
                    maiRoomsInfoMapper.insert(maiRoomsInfo);
                }else {
                    maiRoomsInfoMapper.update(maiRoomsInfo,wrapper);
                }

            }
        }
    }




    @Autowired
    private CumRechargeMapper cumRechargeMapper;

    public void recordCumRecharge(long time,long endTime,String tab){

        String tableName="collect_data_"+tab;
        QueryWrapper<SysDictDetail> wrapper1=new QueryWrapper<>();
        wrapper1.eq("dict_id",16);
        wrapper1.le("dict_sort",901);
        List<SysDictDetail> list1=sysDictDetailMapper.selectList(wrapper1);
        SysDictDetail sysDictDetail1=new SysDictDetail();
        sysDictDetail1.setValue("total");
        list1.add(sysDictDetail1);
        if(list1.size()>0){
            QueryWrapper<CumRechargeEntity> wrapper=new QueryWrapper<>();
            wrapper.eq("time",time);
            cumRechargeMapper.delete(wrapper);
            for (SysDictDetail sysDictDetail:list1) {

                CumRechargeEntity cumRechargeEntity = new CumRechargeEntity();

                cumRechargeEntity.setChannel(sysDictDetail.getValue());
                cumRechargeEntity.setTime((int) time);
                Criteria criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000092);
                if(!sysDictDetail.getValue().equals("total")) {
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                        cumRechargeEntity.setTheFather("total");
                    }
                    else {
                        cumRechargeEntity.setTheFather(sysDictDetail.getValue().split("_")[0].replace("h5","")+"_total");
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                Aggregation aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("v1"),
                       Aggregation.group("numid").count().as("v1")
                );
                AggregationResults<StaticeEntity> ar = mongoTemplate.aggregate(aggregation, tableName, StaticeEntity.class);
                List<StaticeEntity> list = ar.getMappedResults();
                if (list.size() > 0) {
                    cumRechargeEntity.setEnterCumRecharge(list.get(0).getV1());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000093);
                if(!sysDictDetail.getValue().equals("total")) {
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }
                    else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("v1"),
                        Aggregation.group("numid").count().as("v1")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, StaticeEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    cumRechargeEntity.setCrTurnMj(list.get(0).getV1());
                }


                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000094);
                if(!sysDictDetail.getValue().equals("total")) {
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }
                    else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("v1"),
                        Aggregation.group("numid").count().as("v1")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, StaticeEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    cumRechargeEntity.setCrToRecharge(list.get(0).getV1());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000105);
                criteria.and("value").is(1);
                if(!sysDictDetail.getValue().equals("total")) {
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }
                    else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("v1"),
                        Aggregation.group("numid").count().as("v1")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, StaticeEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    cumRechargeEntity.setCrToPeople1(list.get(0).getV1());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000105);
                criteria.and("value").is(2);
                if(!sysDictDetail.getValue().equals("total")) {
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }
                    else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("v1"),
                        Aggregation.group("numid").count().as("v1")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, StaticeEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    cumRechargeEntity.setCrToPeople2(list.get(0).getV1());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000105);
                criteria.and("value").is(3);
                if(!sysDictDetail.getValue().equals("total")) {
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }
                    else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("v1"),
                        Aggregation.group("numid").count().as("v1")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, StaticeEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    cumRechargeEntity.setCrToPeople3(list.get(0).getV1());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000105);
                criteria.and("value").is(4);
                if(!sysDictDetail.getValue().equals("total")) {
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }
                    else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("v1"),
                        Aggregation.group("numid").count().as("v1")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, StaticeEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    cumRechargeEntity.setCrToPeople4(list.get(0).getV1());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000105);
                criteria.and("value").is(5);
                if(!sysDictDetail.getValue().equals("total")) {
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }
                    else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("v1"),
                        Aggregation.group("numid").count().as("v1")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, StaticeEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    cumRechargeEntity.setCrToPeople5(list.get(0).getV1());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000105);
                criteria.and("value").is(6);
                if(!sysDictDetail.getValue().equals("total")) {
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }
                    else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("v1"),
                        Aggregation.group("numid").count().as("v1")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, StaticeEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    cumRechargeEntity.setCrToPeople6(list.get(0).getV1());
                }

                criteria = new Criteria();
                criteria.and("time").gte(time).lte(endTime);
                criteria.and("evid").is(1000000105);
                criteria.and("value").is(7);
                if(!sysDictDetail.getValue().equals("total")) {
                    if(sysDictDetail.getDictSort()==900){
                        criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                    }
                    else {
                        criteria.and("channel").is(sysDictDetail.getValue());
                    }
                }
                aggregation = Aggregation.newAggregation(
                        Aggregation.match(criteria),
                        Aggregation.group("numid").count().as("v1"),
                        Aggregation.group("numid").count().as("v1")
                );
                ar = mongoTemplate.aggregate(aggregation, tableName, StaticeEntity.class);
                list = ar.getMappedResults();
                if (list.size() > 0) {
                    cumRechargeEntity.setCrToPeople7(list.get(0).getV1());
                }
                cumRechargeMapper.insert(cumRechargeEntity);
               // System.out.println(cumRechargeEntity);
            }
        }
    }


    public void newBodyAdByChannel(long time,long endTime,String tab){

        String tableName="collect_data_"+tab;
        Object evids[]=new Object[]{1000000044,1000000046,1000000047,1000000048,1000000050,1000000056,1000000057,1000000064,1000000082,1000000104,1000000111,1000000130,1000000131,1000000132,1000000133,1000000134,1000000135,1000000136
                ,1000000137,1000000138,1000000139,1000000140,1000000141,1000000142,1000000143,1000000144,1000000145,1000000146,1000000147,1000000148,1000000149,1000000150,1000000151,1000000152,1000000153,1000000154,1000000155,1000000156,1000000157,1000000160};
       // Object userId[]=new Object[];
        QueryWrapper<SysDictDetail> wrapper1=new QueryWrapper<>();
        wrapper1.eq("dict_id",16);
        wrapper1.le("dict_sort",988);
        wrapper1.orderByDesc("dict_sort");
        Criteria criteria1=new Criteria();
        criteria1.and("channel").is("h5gdmjxl_wechat");
        criteria1.and("reg_time").gte(time).lt(endTime);
        List<UserEntity> userList=mTemplate.find(new Query().addCriteria(criteria1),UserEntity.class,"user");
        System.out.println(userList);
        if(userList.size()>0) {
            String[] uis=new String[userList.size()];int iu=0;
            for(UserEntity userEntity:userList){
                uis[iu]=userEntity.getUserid();
                iu++;
            }
            List<SysDictDetail> list1 = new ArrayList<>();  //sysDictDetailMapper.selectList(wrapper1);
            SysDictDetail sysDictDetail1 = new SysDictDetail();
            sysDictDetail1.setValue("h5gdmjxl_wechat");
            sysDictDetail1.setDictSort(52);
            list1.add(sysDictDetail1);
            if (list1.size() > 0) {
                for (SysDictDetail sysDictDetail : list1) {
                    MaiAdInfo maiAdInfo = new MaiAdInfo();
                    maiAdInfo.setChannel(sysDictDetail.getValue());
                    maiAdInfo.setTime((int) time);
                    maiAdInfo.setTheFather("newBody");
                    Criteria criteria = new Criteria();
                    criteria.and("time").gte(time).lte(endTime);
                    criteria.and("evid").in(evids);
                    criteria.and("numid").in(uis);
                    if (sysDictDetail.getDictSort() != null && sysDictDetail.getDictSort() == 987) {
                        if (sysDictDetail.getValue().equals("h5hzmjxl_wechat") || sysDictDetail.getValue().equals("h5hzmjxl_qq") || sysDictDetail.getValue().equals("h5gdmjxl_wechat") || sysDictDetail.getValue().equals("h5hcmjxl_wechat")) {
                            criteria.and("channel").is(sysDictDetail.getValue());
                            criteria.orOperator(Criteria.where("invite_channel").exists(false), Criteria.where("invite_channel").is(""));
                        } else {
                            criteria.and("invite_channel").is(sysDictDetail.getValue());
                        }
                    } else if (sysDictDetail.getDictSort() != 99) {
                        if (sysDictDetail.getDictSort() == 900 || sysDictDetail.getDictSort() == 910) {
                            criteria.and("channel").regex(sysDictDetail.getValue().split("_")[0]);
                        } else {
                            criteria.and("channel").is(sysDictDetail.getValue());
                        }
                    }
                    Aggregation aggregation = Aggregation.newAggregation(
                            Aggregation.match(criteria),
                            Aggregation.group("numid").count().as("num")
                    );
                    AggregationResults<TaskEntity> ar;
                    if (sysDictDetail.getValue().equals("totalcl") || sysDictDetail.getValue().indexOf("cl_") > 0) {
                        ar = sixthMongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                    } else {
                        ar = mongoTemplate.aggregate(aggregation, tableName, TaskEntity.class);
                    }
                    List<TaskEntity> list = ar.getMappedResults();
                    if (list.size() > 0) {
                        maiAdInfo.setUsers((long) list.size());
                    }
                  //商城钻石广告
                    maiAdInfo.setWatchAdStoreDiamond(getbodyNumber(1000000044, 1, time, endTime, sysDictDetail, tableName,uis));
                    //失败商城钻石广告
                    maiAdInfo.setFailWatchAdStoreDiamond(getbodyNumber(1000000044, 0, time, endTime, sysDictDetail, tableName,uis));
                    //对局免输广告
                    maiAdInfo.setWatchAdLose(getbodyNumber(1000000046, 1, time, endTime, sysDictDetail, tableName,uis));
                    //失败对局免输广告
                    maiAdInfo.setFailWatchAdLose(getbodyNumber(1000000046, 0, time, endTime, sysDictDetail, tableName,uis));
                    //对局救济金广告
                    maiAdInfo.setWatchAdBroke(getbodyNumber(1000000047, 1, time, endTime, sysDictDetail, tableName,uis));
                    //失败对局救济金广告
                    maiAdInfo.setFailWatchAdBroke(getbodyNumber(1000000047, 0, time, endTime, sysDictDetail, tableName,uis));
                    //转盘广告
                    maiAdInfo.setWatchAdHappyLoot(getbodyNumber(1000000048, 1, time, endTime, sysDictDetail, tableName,uis));
                    //失败转盘广告
                    maiAdInfo.setFailWatchAdHappyLoot(getbodyNumber(1000000048, 0, time, endTime, sysDictDetail, tableName,uis));
                    //7日签到广告
                    maiAdInfo.setWatchAdSignSeven(getbodyNumber(1000000050, 1, time, endTime, sysDictDetail, tableName,uis));
                    //失败7日签到广告
                    maiAdInfo.setFailWatchAdSignSeven(getbodyNumber(1000000050, 0, time, endTime, sysDictDetail, tableName,uis));
                    //好牌开局
                    maiAdInfo.setWatchAdGoodCard(getbodyNumber(1000000056, 1, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdGoodCard(getbodyNumber(1000000056, 0, time, endTime, sysDictDetail, tableName,uis));

                    //红中开局
                    maiAdInfo.setWatchAdHongzhong(getbodyNumber(1000000057, 2, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdHongzhong(getbodyNumber(1000000057, 0, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setWatchAdHongzhongjl(getbodyNumber(1000000057, 3, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setWatchAdHongzhongbxp(getbodyNumber(1000000057, 5, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdHongzhongbxp(getbodyNumber(1000000057, 4, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdHongzhongjl(getbodyNumber(1000000057, 1, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setWatchAdHongzhongqs(getbodyNumber(1000000057, 7, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdHongzhongqs(getbodyNumber(1000000057, 6, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setWatchAdHongzhong4(getbodyNumber(1000000057, 9, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdHongzhong4(getbodyNumber(1000000057, 8, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setWatchAdHongzhongkl(getbodyNumber(1000000057, 11, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdHongzhongkl(getbodyNumber(1000000057, 10, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setWatchAdHongzhongklqs(getbodyNumber(1000000057, 13, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdHongzhongklqs(getbodyNumber(1000000057, 12, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setWatchAdHongzhongxl8(getbodyNumber(1000000057, 15, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdHongzhongxl8(getbodyNumber(1000000057, 14, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setWatchAdQianceng(getbodyNumber(1000000057, 17, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdQianceng(getbodyNumber(1000000057, 16, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setWatchAdBagang(getbodyNumber(1000000057, 19, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdBagang(getbodyNumber(1000000057, 18, time, endTime, sysDictDetail, tableName,uis));

                    //新用户点击商城
                    maiAdInfo.setWatchAdBenefit(getbodyNumber(1000000064, 1, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdBenefit(getbodyNumber(1000000064, 0, time, endTime, sysDictDetail, tableName,uis));

                    maiAdInfo.setMrtWatchAdGoodCard(getbodyNumber(1000000082, 1, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailMrtWatchAdGoodCard(getbodyNumber(1000000082, 0, time, endTime, sysDictDetail, tableName,uis));

                    maiAdInfo.setWatchAdWealthCom(getbodyNumber(1000000104, 1, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdWealthCom(getbodyNumber(1000000104, 0, time, endTime, sysDictDetail, tableName,uis));

                    maiAdInfo.setWatchAdPropsFuka(getbodyNumber(1000000111, 3, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdPropsFuka(getbodyNumber(1000000111, 0, time, endTime, sysDictDetail, tableName,uis));

                    maiAdInfo.setWatchAdPropsFeng(getbodyNumber(1000000111, 4, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdPropsFeng(getbodyNumber(1000000111, 2, time, endTime, sysDictDetail, tableName,uis));

                    maiAdInfo.setWatchAdPropsJia(getbodyNumber(1000000111, 5, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdPropsJia(getbodyNumber(1000000111, 1, time, endTime, sysDictDetail, tableName,uis));

                    maiAdInfo.setWatchAdMatchJoin(getbodyNumber(1000000130, 1, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdMatchJoin(getbodyNumber(1000000130, 0, time, endTime, sysDictDetail, tableName,uis));
                    if (sysDictDetail.getValue().equals("totalcl") || sysDictDetail.getValue().indexOf("cl_") > 0) {
                        maiAdInfo.setWatchAdBigOrSmall(getbodyNumber(1000000131, 1, time, endTime, sysDictDetail, tableName,uis));
                        maiAdInfo.setFailWatchAdBigOrSmall(getbodyNumber(1000000131, 0, time, endTime, sysDictDetail, tableName,uis));
                    } else {
                        maiAdInfo.setWatchAdBigOrSmall(getbodyNumber(1000000157, 1, time, endTime, sysDictDetail, tableName,uis));
                        maiAdInfo.setFailWatchAdBigOrSmall(getbodyNumber(1000000157, 0, time, endTime, sysDictDetail, tableName,uis));
                    }
                    maiAdInfo.setWatchAdGodBlessJP(getbodyNumber(1000000160, 1, time, endTime, sysDictDetail, tableName,uis));
                    maiAdInfo.setFailWatchAdGodBlessJP(getbodyNumber(1000000160, 0, time, endTime, sysDictDetail, tableName,uis));

                    maiAdInfo.setAllWatch(
                            maiAdInfo.getWatchAdLose() + maiAdInfo.getFailWatchAdLose() + maiAdInfo.getFailWatchAdBroke() + maiAdInfo.getWatchAdHappyLoot() + maiAdInfo.getFailWatchAdHappyLoot() + maiAdInfo.getWatchAdSignSeven() +
                                    maiAdInfo.getFailWatchAdSignSeven() + maiAdInfo.getWatchAdGoodCard() + maiAdInfo.getFailWatchAdGoodCard() + maiAdInfo.getWatchAdHongzhong() + maiAdInfo.getFailWatchAdHongzhong() + maiAdInfo.getWatchAdHongzhongjl() +
                                    maiAdInfo.getFailWatchAdHongzhongjl() + maiAdInfo.getMrtWatchAdGoodCard() + maiAdInfo.getFailMrtWatchAdGoodCard() + maiAdInfo.getWatchAdMatchJoin() + maiAdInfo.getFailWatchAdMatchJoin() +
                                    maiAdInfo.getWatchAdPropsFuka() + maiAdInfo.getFailWatchAdPropsFuka() + maiAdInfo.getWatchAdPropsFeng() + maiAdInfo.getFailWatchAdPropsFeng() + maiAdInfo.getWatchAdPropsJia() + maiAdInfo.getFailWatchAdPropsJia() +
                                    maiAdInfo.getWatchAdHongzhong4() + maiAdInfo.getWatchAdHongzhongqs() + maiAdInfo.getWatchAdHongzhongkl() + maiAdInfo.getWatchAdHongzhongklqs() + maiAdInfo.getFailWatchAdHongzhong4() + maiAdInfo.getFailWatchAdHongzhongqs() + maiAdInfo.getFailWatchAdHongzhongkl() + maiAdInfo.getFailWatchAdHongzhongklqs()
                                    + maiAdInfo.getWatchAdBigOrSmall() + maiAdInfo.getFailWatchAdBigOrSmall() + maiAdInfo.getWatchAdGodBlessJP() + maiAdInfo.getFailWatchAdGodBlessJP() + maiAdInfo.getWatchAdQianceng() + maiAdInfo.getFailWatchAdQianceng() + maiAdInfo.getFailWatchAdBagang() + maiAdInfo.getWatchAdBagang()
                    );
                    maiAdInfo.setAllAcWatch(
                            maiAdInfo.getWatchAdLose() + maiAdInfo.getWatchAdHappyLoot() + maiAdInfo.getWatchAdSignSeven() + maiAdInfo.getWatchAdHongzhong4() + maiAdInfo.getWatchAdHongzhongqs() + maiAdInfo.getWatchAdHongzhongkl() + maiAdInfo.getWatchAdHongzhongklqs() +
                                    maiAdInfo.getWatchAdGoodCard() + maiAdInfo.getWatchAdHongzhong() + maiAdInfo.getWatchAdHongzhongjl() + maiAdInfo.getMrtWatchAdGoodCard() + maiAdInfo.getWatchAdPropsFuka() + maiAdInfo.getWatchAdPropsFeng() + maiAdInfo.getWatchAdPropsJia() +
                                    maiAdInfo.getWatchAdMatchJoin() + maiAdInfo.getWatchAdBigOrSmall() + maiAdInfo.getWatchAdGodBlessJP() + maiAdInfo.getWatchAdQianceng() + maiAdInfo.getWatchAdBagang()
                    );
                    long total = 0;
                    total=userList.size();
//                    if (sysDictDetail.getDictSort() == 987) {
//                        if (sysDictDetail.getValue().equals("h5hzmjxl_wechat") || sysDictDetail.getValue().equals("h5hzmjxl_qq") || sysDictDetail.getValue().equals("h5gdmjxl_wechat") || sysDictDetail.getValue().equals("h5hcmjxl_wechat")) {
//                            total = mongoT.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("invite.channel").is("").and("channel").is(sysDictDetail.getValue())), UserEntity.class);
//                        } else {
//
//                            total = mongoT.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("invite.channel").is(sysDictDetail.getValue())), UserEntity.class);
//
//                        }
//                    } else if (sysDictDetail.getDictSort() == 900) {
//                        total = mongoT.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("channel").regex(sysDictDetail.getValue().split("_")[0])), UserEntity.class);
//                    } else if (sysDictDetail.getDictSort() == 910) {
//                        total = fiveMongoTemplate.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("channel").regex(sysDictDetail.getValue().split("_")[0])), UserEntity.class);
//                    } else if (sysDictDetail.getDictSort() == 99) {
//                        if (sysDictDetail.getValue().equals("total")) {
//                            total = mongoT.count(new Query(Criteria.where("last_time").gte(time).lte(endTime)), UserEntity.class);
//                        } else {
//                            total = fiveMongoTemplate.count(new Query(Criteria.where("last_time").gte(time).lte(endTime)), UserEntity.class);
//                        }
//                    } else {
//                        total = mongoT.count(new Query(Criteria.where("last_time").gte(time).lte(endTime).and("channel").is(sysDictDetail.getValue())), UserEntity.class);
//
//                    }
                    maiAdInfo.setActNum(total);

                    QueryWrapper<MaiAdInfo> wrapper = new QueryWrapper<>();
                    wrapper.eq("time", time);
                    wrapper.eq("channel", maiAdInfo.getChannel());
                    if (StringUtils.isNotEmpty(maiAdInfo.getTheFather())) {
                        wrapper.eq("the_father", maiAdInfo.getTheFather());
                    }
                    MaiAdInfo maiAdInfo1 = maiAdInfoMapper.selectOne(wrapper);
                    if (maiAdInfo1 == null) {
                        maiAdInfoMapper.insert(maiAdInfo);
                    } else {
                        maiAdInfoMapper.update(maiAdInfo, wrapper);
                    }
                }
            }
        }
    }

}
